home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-06-19 | 3.2 KB | 112 lines |
- package symantec.itools.awt;
-
-
- import java.awt.Panel;
- import java.awt.Checkbox;
- import java.awt.CheckboxGroup;
- import java.awt.Component;
-
- // 01/27/97 RKM Changed moveIntoGroup to preserve checkbox's state
- // 01/29/97 TWB Integrated changes from Windows and RKM's changes
- // 01/29/97 TWB Integrated changes from Macintosh
-
- /**
- * Creates an invisible rectangular panel area that automatically groups
- * the RadioButtons that it contains.
- * <p>
- * All the RadioButtons within the RadioButtonGroupPanel act together. Only
- * one of the RadioButtons can be "on" at a time.
- * <p>
- * @version 1.0, Nov 26, 1996
- * @author Symantec
- */
-
- public class RadioButtonGroupPanel
- extends Panel
- {
- private CheckboxGroup group;
-
- /**
- * Constructs a RadioButtonGroupPanel.
- */
- public RadioButtonGroupPanel()
- {
- group = new CheckboxGroup();
- }
-
- private void moveIntoGroup(Component c)
- {
- if (c instanceof Checkbox)
- {
- //Cast the component to a checkbox
- Checkbox checkBox = ((Checkbox)c);
-
- //Save the state
- boolean savedState = checkBox.getState();
-
- //Set up the checkbox group
- checkBox.setCheckboxGroup(group);
-
- //Restore the state if it was true
- if (savedState)
- checkBox.setState(savedState);
- }
- }
-
- /**
- * Adds a component to the end of this container.
- * This is a standard Java AWT method which gets called to add a
- * component to a container. The specified component is added to
- * the end of this container.
- *
- * @param c the component to add
- * @return the added component
- * @see java.awt.Container#remove
- */
- public Component add(Component c)
- {
- moveIntoGroup(c);
-
- return super.add(c);
- }
-
- /**
- * Inserts a component into this container at the given position.
- * This is a standard Java AWT method which gets called to add a
- * component to a container. The specified component is added to
- * this container at the given zero-relative position index. A
- * position index of -1 appends the component to the end.
- *
- * @param c the component to add
- * @param p the zero-relative index at which to add the component or -1 for end
- * @return the added component
- * @see java.awt.Container#remove
- */
- public Component add(Component c, int p)
- {
- moveIntoGroup(c);
-
- return super.add(c, p);
- }
-
- /**
- * Adds a component to the end of this container and to the layout manager.
- * This is a standard Java AWT method which gets called to add a
- * component to a container. The specified component is added to
- * the end of this container, and also added to this container's
- * layout manager with the given name.
- *
- * @param s the positioning directive for the layout manager
- * @param c the component to add
- * @return the added component
- * @see java.awt.Container#remove
- */
- public Component add(String s, Component c)
- {
- moveIntoGroup(c);
-
- return super.add(s, c);
- }
- }
-
-